
#include "validate.h"
#include "vp/SignalServiceId.h"

static uint16_t RX1Oper[]={0xa11,1001};
static uint16_t RX2Oper[]={0xa11,1002};
static uint16_t ASDMOper[]={0xa11,0x3e7,8,9,10,11,12,17,18,24,26,27,30,34,39,40,41,42,46,47,51,53,55,57,58,64,74,78,79,89,90,103,105,107,109,111,119,127,129,134,136,138,152,160,168,170,172,176,180,188,201,218,229,238,250,269,279,281,283,285,298,300,308};
static uint16_t AUDOper[]={0xa11,0x3e7,1,10,11,41,89,135,3};
static uint16_t BBMOper[]={0xa11,0x3e7,2,3,6};
static uint16_t CCSMOper[]={0xa11,0x3e7,2};
static uint16_t CDMOper[]={0xa11,0x3e7,1,3,20,24,25,66,67,116,132,145,188,212,215,237,238,241,242,254,302,303,340,394,395,442,511,531,564,574,599,1289,1292,1293,1600,1601,1602,701,702,722,723,724,35,36,189,213,214,216,217,220,221,266,549,581,606,611};
static uint16_t CEMOper[]={0xa11,0x3e7,2,13,21,24,25,32,36,44,46,49,50,51,52,58,59,73,100,101,102,103,104,105,111,112,126,129,150,151,169,178,191,193,202,210,242,243,268,269,288,305,315,316,319,325,330,331,332,333,340,342,346,348,350,353,355,363,439,451,460,462,463,492,493,532,533,534,535,536,537,538,539,540,541,542,543,544,545,578,579,580,581,582,583,584,585,888,1704,1705,1800,1901,39,163,249,318,440,487,490};
static uint16_t DISOper[]={23};
static uint16_t FPLOper[]={0xa11,0x3e7,1,2,3,4,5,7,8};
static uint16_t HODOper[]={0xa11,0x3e7};
static uint16_t HUDOper[]={0xa11,0x3e7,6};
static uint16_t SRSOper[]={0xa11,0x3e7,7};
static uint16_t SWSMOper[]={0xa11,0x3e7};
static uint16_t VDDMOper[]={0xa11,0x3e7,2,6,7,13,14,15,27,28,29,32,39,43,44,46,66,69,75,76,90,170,179,181,186,63,71};
static uint16_t VGMOper[]={0xa11,0x3e7,23,35,138,139,175,176,178,179,203,270,374,484,517,1418,11,74,94};
static uint16_t CARCONFIGOper[]={0xa11,0xc8};
static uint16_t CARCONFIGTHOUSANDOper[]={0xa11,0xc8};
static uint16_t TIMEOUTOper[]={0xa11,0xc8};
static uint16_t APPLOGOper[]={1,2577};
static uint16_t APVPPULSEOper[]={200,1};
static uint16_t AUDIORADIOOper[]={200,1,2};
static uint16_t CLIMATEOper[]={200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,2577};
static uint16_t DIAGDIDOper[]={200,1,2,3,4,5,6,7,8,9,10,11,2577,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33};
static uint16_t DIAGOTAOper[]={200,2577,1,2,3};
static uint16_t DIAGPROXYOper[]={200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21};
static uint16_t DIAGVFCOper[]={200};
static uint16_t DTCOper[]={1,2,3};
static uint16_t ECVERSIONOper[]={200};
static uint16_t EXTAMPCTRLOper[]={200};
static uint16_t MCULOGPANICOper[]={200};
static uint16_t POWEROper[]={200,2577,3,4,5,8,10,11,12,13,16,17};
static uint16_t SERVICEREMINDEROper[]={200,1};
static uint16_t SWCODOOFTRIPINFOOper[]={200};
static uint16_t SWCWARNINGSOUNDOper[]={1,2};
static uint16_t VFCIPWAKEUPOper[]={200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,2577};
static uint16_t VINOper[]={200};
static uint16_t VINDIFFMSGOper[]={200};
static uint16_t VPVERSIONOper[]={200};

namespace ecarx::transfer::validate {
    const ValidOperationArray getValidOperation(const int serviceId){
        ValidOperationArray ret;
        switch (serviceId) {
            case EcarXSignalServiceID::serviceID_RX1:{
                ret.len=2;
                ret.oper_ids = RX1Oper;
                break;
            }
            case EcarXSignalServiceID::serviceID_RX2:{
                ret.len=2;
                ret.oper_ids = RX2Oper;
                break;
            }
            case EcarXSignalServiceID::serviceID_ASDM:{
                ret.len=63;
                ret.oper_ids = ASDMOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_AUD:{
                ret.len=9;
                ret.oper_ids = AUDOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_BBM:{
                ret.len=5;
                ret.oper_ids = BBMOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_CCSM:{
                ret.len=3;
                ret.oper_ids = CCSMOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_CDM:{
                ret.len=56;
                ret.oper_ids = CDMOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_CEM:{
                ret.len=99;
                ret.oper_ids = CEMOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_DIS:{
                ret.len=1;
                ret.oper_ids = DISOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_FPL:{
                ret.len=9;
                ret.oper_ids = FPLOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_HOD:{
                ret.len=2;
                ret.oper_ids = HODOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_HUD:{
                ret.len=3;
                ret.oper_ids = HUDOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_SRS:{
                ret.len=3;
                ret.oper_ids = SRSOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_SWSM:{
                ret.len=2;
                ret.oper_ids = SWSMOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_VDDM:{
                ret.len=27;
                ret.oper_ids = VDDMOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_VGM:{
                ret.len=19;
                ret.oper_ids = VGMOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_CARCONFIG:{
                ret.len=2;
                ret.oper_ids = CARCONFIGOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_CARCONFIGTHOUSAND:{
                ret.len=2;
                ret.oper_ids = CARCONFIGTHOUSANDOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_TIMEOUT:{
                ret.len=2;
                ret.oper_ids = TIMEOUTOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_APPLOG:{
                ret.len=2;
                ret.oper_ids = APPLOGOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_APVPPULSE:{
                ret.len=2;
                ret.oper_ids = APVPPULSEOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_AUDIORADIO:{
                ret.len=3;
                ret.oper_ids = AUDIORADIOOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_CLIMATE:{
                ret.len=43;
                ret.oper_ids = CLIMATEOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_DIAGDID:{
                ret.len=35;
                ret.oper_ids = DIAGDIDOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_DIAGOTA:{
                ret.len=5;
                ret.oper_ids = DIAGOTAOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_DIAGPROXY:{
                ret.len=22;
                ret.oper_ids = DIAGPROXYOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_DIAGVFC:{
                ret.len=1;
                ret.oper_ids = DIAGVFCOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_DTC:{
                ret.len=3;
                ret.oper_ids = DTCOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_ECVERSION:{
                ret.len=1;
                ret.oper_ids = ECVERSIONOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_EXTAMPCTRL:{
                ret.len=1;
                ret.oper_ids = EXTAMPCTRLOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_MCULOGPANIC:{
                ret.len=1;
                ret.oper_ids = MCULOGPANICOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_POWER:{
                ret.len=12;
                ret.oper_ids = POWEROper;
                break;
            }
            case EcarXSignalServiceID::serviceID_SERVICEREMINDER:{
                ret.len=2;
                ret.oper_ids = SERVICEREMINDEROper;
                break;
            }
            case EcarXSignalServiceID::serviceID_SWCODOOFTRIPINFO:{
                ret.len=1;
                ret.oper_ids = SWCODOOFTRIPINFOOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_SWCWARNINGSOUND:{
                ret.len=2;
                ret.oper_ids = SWCWARNINGSOUNDOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_VFCIPWAKEUP:{
                ret.len=71;
                ret.oper_ids = VFCIPWAKEUPOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_VIN:{
                ret.len=1;
                ret.oper_ids = VINOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_VINDIFFMSG:{
                ret.len=1;
                ret.oper_ids = VINDIFFMSGOper;
                break;
            }
            case EcarXSignalServiceID::serviceID_VPVERSION:{
                ret.len=1;
                ret.oper_ids = VPVERSIONOper;
                break;
            }

        }
        return ret;
    }

    bool availableServiceID(const int serviceId){
        return serviceId == EcarXSignalServiceID::serviceID_RX1 ||
               serviceId == EcarXSignalServiceID::serviceID_RX2 ||
               serviceId == EcarXSignalServiceID::serviceID_ASDM ||
               serviceId == EcarXSignalServiceID::serviceID_AUD ||
               serviceId == EcarXSignalServiceID::serviceID_BBM ||
               serviceId == EcarXSignalServiceID::serviceID_CCSM ||
               serviceId == EcarXSignalServiceID::serviceID_CDM ||
               serviceId == EcarXSignalServiceID::serviceID_CEM ||
               serviceId == EcarXSignalServiceID::serviceID_DIS ||
               serviceId == EcarXSignalServiceID::serviceID_FPL ||
               serviceId == EcarXSignalServiceID::serviceID_HOD ||
               serviceId == EcarXSignalServiceID::serviceID_HUD ||
               serviceId == EcarXSignalServiceID::serviceID_SRS ||
               serviceId == EcarXSignalServiceID::serviceID_SWSM ||
               serviceId == EcarXSignalServiceID::serviceID_VDDM ||
               serviceId == EcarXSignalServiceID::serviceID_VGM ||
               serviceId == EcarXSignalServiceID::serviceID_CARCONFIG ||
               serviceId == EcarXSignalServiceID::serviceID_CARCONFIGTHOUSAND ||
               serviceId == EcarXSignalServiceID::serviceID_TIMEOUT ||
               serviceId == EcarXSignalServiceID::serviceID_APPLOG ||
               serviceId == EcarXSignalServiceID::serviceID_APVPPULSE ||
               serviceId == EcarXSignalServiceID::serviceID_AUDIORADIO ||
               serviceId == EcarXSignalServiceID::serviceID_CLIMATE ||
               serviceId == EcarXSignalServiceID::serviceID_DIAGDID ||
               serviceId == EcarXSignalServiceID::serviceID_DIAGOTA ||
               serviceId == EcarXSignalServiceID::serviceID_DIAGPROXY ||
               serviceId == EcarXSignalServiceID::serviceID_DIAGVFC ||
               serviceId == EcarXSignalServiceID::serviceID_DTC ||
               serviceId == EcarXSignalServiceID::serviceID_ECVERSION ||
               serviceId == EcarXSignalServiceID::serviceID_EXTAMPCTRL ||
               serviceId == EcarXSignalServiceID::serviceID_MCULOGPANIC ||
               serviceId == EcarXSignalServiceID::serviceID_POWER ||
               serviceId == EcarXSignalServiceID::serviceID_SERVICEREMINDER ||
               serviceId == EcarXSignalServiceID::serviceID_SWCODOOFTRIPINFO ||
               serviceId == EcarXSignalServiceID::serviceID_SWCWARNINGSOUND ||
               serviceId == EcarXSignalServiceID::serviceID_VFCIPWAKEUP ||
               serviceId == EcarXSignalServiceID::serviceID_VIN ||
               serviceId == EcarXSignalServiceID::serviceID_VINDIFFMSG ||
               serviceId == EcarXSignalServiceID::serviceID_VPVERSION;
    }
}
